<?php
if (isset($data['courses_id']) && !empty($data['courses_id'])) {
    $courseName = $data['course_titile'];
    $userDetails = getUserTypeByClassCourse('Courses', $data['courses_id']);
    $imagePath = getImagePathByClassCourse('Courses', $data['courses_id']);
    $url = $this->createAbsoluteUrl('/courses-'.$data['courses_id'].'/'.$data['course_seo_title']);
    $session = Courses::countCousrseBatchDateSession($data['courses_id']);
   $imageName = (ClassImage::getCoursesPrimaryImage($data['courses_id']) != '') ? getRequestbaseUrl() . getuploadFolderDir() . SkillConfig::getClassCourseImagePath($imagePath) . '207X145/' . ClassImage::getCoursesPrimaryImage($data['courses_id']) : getWorkNoshopimage(SkillConfig::skill_home_category_no_image);
    $booknow = ($data['course_type_id'] == COURSE_CLASS_TYPE) ? 'Close this session' : 'Close this session';
    $priceRange = CourseBatche::findMinMaxPriceByClassbatchforCategoryPage($data['courses_id']);
    $trainerResponse = MakeQuery::trainerResponseRate($data['front-user'], $data['backend-user']);
    $coursePrice = 'COURSE PRICE';
   $cssLevel = LevelCssClassName('Courses', $data['courses_id']);
    $levelType = classCourseLevelType('Courses', $data['courses_id']);
    $locationName = ClassVenue::getLocationNameBycourseVenueId($data['course_venue_id']);
    $batchStartDate = date('D, d  M', strtotime($data['start_date'])) . '  -  ' . date('D, d  M', strtotime($data['end_date']));
} else {
    $coursePrice = 'CLASS PRICE';
    $courseName = $data['class_titile'];
    $userDetails = getUserTypeByClassCourse('Classes', $data['classes_id']);
    $imagePath = getImagePathByClassCourse('Classes', $data['classes_id']);
    $url = $this->createAbsoluteUrl('/workshop-'.$data['classes_id'].'/'.$data['class_seo_title']);
    $session = CLASS_NO_SESSION;
     $imageName = (ClassImage::getPrimaryImage($data['classes_id']) != '') ? getRequestbaseUrl() . getuploadFolderDir() . SkillConfig::getClassCourseImagePath($imagePath) . '207X145/' . ClassImage::getPrimaryImage($data['classes_id']) : getWorkNoshopimage(SkillConfig::skill_home_category_no_image);
    $booknow = ($data['class_type_id'] == CURATED_CLASS_TYPE) ? 'Close this session' : 'Close this session';
    $priceRange = ClassBatch::findMinMaxPriceByClassbatchforCategoryPage($data['classes_id']);
    $trainerResponse = MakeQuery::trainerResponseRate($data['front-user'], $data['backend-user']);
  $levelType = classCourseLevelType('Classes', $data['classes_id']);
    $cssLevel = LevelCssClassName('Classes', $data['classes_id']);
    $locationName = ClassVenue::getLocationNameByVenueId($data['class_venue_id']);
    $batchStartDate = date('D, d  M', strtotime($data['start_date']));
}

$indexes = $index + 1;
if (($indexes % 3) == 0) {

    echo '<div class="row">';
};
?>
<div class="col-lg-4 col-md-4 col-sm-6">
    <a href="<?php echo $url; ?>">
        <div class="thumbnail">
            <?php echo '<img src="' . $imageName . '"  alt="' . $courseName . '">'; ?>
            <div class="caption">
                <h4><?php echo $courseName; ?></h4>
                <p class="trainer-name">By:<?php echo substr($userDetails->first_name . '  ' . $userDetails->last_name, 0, 20); ?></p>
                <div class="workinfo">
                    <span><?php echo $locationName; ?> <span class="rupee"><?php echo $priceRange; ?></span></span>
                    <span><?php echo $batchStartDate; ?></span>
                </div>
                <div class="session">
                    <ul class="list-unstyled sessioninfo">
                        <li>
                            <span>session</span>
                            <span><?php echo $session; ?></span>
                        </li>
                        <li>
                            <span class="<?php echo $cssLevel; ?>"></span>
                            <span>Level</span>
                            <span><?php echo $levelType; ?></span>
                        </li>
                        <li>
                            <span>Response Rate</span>
                            <span><?php echo (!empty($trainerResponse) ? $trainerResponse . '%' : TRAINER_RESPONSE_RATE); ?></span>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </a>
</div>

<?php
if (($indexes % 3) == 0) {
    echo'<div class="gap"></div></div>';
};
?>
